<template>
    <div>
        <van-search v-model="value" show-action placeholder="请输入搜索关键词" @update:model-value="inputs">
            <template #left>
                <div @click="proxy.$leftClick" class="qu">取消</div>
            </template>
        </van-search>
        <van-list>
            <template v-if="listData.length != 0">
                <van-cell v-for="item in listData" :key="item" @click="clicks(item)">
                    <template #default>
                        <div class="lisSpan">
                            {{ item }}
                        </div>
                    </template>
                </van-cell>
            </template>
            <template v-else>
                <van-divider>没有找到类似分类</van-divider>
            </template>
        </van-list>
    </div>
</template>

<script setup lang="ts">
import { getCurrentInstance, ref } from 'vue';
import { usefenlei } from '@/store/fenlei';
import { useRouter } from 'vue-router';
const value = ref('');
const store = usefenlei();
const router = useRouter()
const { proxy }: any = getCurrentInstance();
let listData = ref<string[]>([])
const inputs = () => {
    listData.value = store.dataList.filter(item => item.includes(value.value))
}
const clicks = (name: string) => {
    // 选中该数据 上传给start属性
    store.foundData(name);
    // 跳转到分类页
    router.push({ name: 'two' })
}
</script>

<style lang="scss">
.van-cell__value  .lisSpan {
    text-align: left;
}
</style>